package com.shi.yoyoshop.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.shi.yoyoshop.bean.Item;
import com.shi.yoyoshop.mapper.ItemMapper;
import com.shi.yoyoshop.service.ItemService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 20556
 * @description 针对表【item】的数据库操作Service实现
 * @createDate 2024-01-05 15:53:59
 */
@Service
public class ItemServiceImpl extends ServiceImpl<ItemMapper, Item>
        implements ItemService {

    @Resource
    private ItemMapper itemMapper;

    @Override
    public boolean saveItem(Item item) {
        return itemMapper.insertItem(item);
    }

    @Override
    public boolean modify(Item item) {
        return itemMapper.updateObj(item);
    }

    @Override
    public List<Item> getItemListByOrderId(Integer orderId) {
        return itemMapper.selectList(new LambdaQueryWrapper<Item>()
                .select(Item::getId, Item::getPrice, Item::getAmount, Item::getGoodId, Item::getOrderId)
                .eq(Item::getOrderId, orderId));
    }
}




